package com.sugo.seckill.order.service;

import com.sugo.seckill.http.HttpResult;
import com.sugo.seckill.page.PageResult;
import com.sugo.seckill.pojo.FrontUser;
import com.sugo.seckill.pojo.TbPayLog;
import com.sugo.seckill.pojo.TbSeckillGoods;
import com.sugo.seckill.pojo.TbSeckillOrder;

/**
 * 服务层接口
 * @author Administrator
 */
public interface SeckillOrderService {

	/**
	 * 返回分页列表
	 * @return
	 */
	public PageResult findPage(int pageNum, int pageSize);
	

	/**
	 * 根据ID获取实体
	 * @param id
	 * @return
	 */
	public TbSeckillOrder findOne(Long id);



	/**
	 * 方式1-1： 普通秒杀下单 会出现库存超卖现象
	 * @param seckillId
	 * @param userId
	 */
	public HttpResult startSubmitOrder(Long seckillId, String userId);

	/**
	 * 方式1-2： 普通秒杀下单 会出现库存超卖现象（多线程的方式）
	 * @param seckillId
	 * @param userId
	 */
	public HttpResult startSubmitOrderMultiThread(Long seckillId, String userId);


	/**
	 * @Description: 3-1 使用aop锁实现库存超卖控制
	 * @Author: hubin
	 * @CreateDate: 2020/9/5 20:48
	 * @UpdateUser: hubin
	 * @UpdateDate: 2020/9/5 20:48
	 * @UpdateRemark: 修改内容
	 * @Version: 1.0
	 */
	public HttpResult startSubmitOrderByAOPLock(Long seckillId, String userId);

	/**
	 * @Description: 4-1 使用队列的方式实现库存控制，以及性能提升
	 * @Author: hubin
	 * @CreateDate: 2020/9/5 20:48
	 * @UpdateUser: hubin
	 * @UpdateDate: 2020/9/5 20:48
	 * @UpdateRemark: 修改内容
	 * @Version: 1.0
	 */
	public HttpResult startSubmitOrderByBockingQueue(Long seckillId, String userId);


	/**
	 * @Description: 5-1 使用数据库悲观锁控制库存
	 * @Author: hubin
	 * @CreateDate: 2020/9/12 20:42
	 * @UpdateUser: hubin
	 * @UpdateDate: 2020/9/12 20:42
	 * @UpdateRemark: 修改内容
	 * @Version: 1.0
	 */
	public HttpResult startSubmitOrderBySQLLock(Long seckillId, String userId);

	public HttpResult startSubmitOrderBySQLLock2(Long seckillId, String userId);


	/**
	 * @Description: 5-3 使用数据库乐观锁锁控制库存
	 * @Author: hubin
	 * @CreateDate: 2020/9/12 21:23
	 * @UpdateUser: hubin
	 * @UpdateDate: 2020/9/12 21:23
	 * @UpdateRemark: 修改内容
	 * @Version: 1.0
	 */
	public HttpResult startSubmitOrderBySQLLock3(Long seckillId, String userId);
	/**
	 * @Description: 2-1 使用程序锁实现库存超卖控制
	 * @Author: hubin
	 * @CreateDate: 2020/9/5 20:48
	 * @UpdateUser: hubin
	 * @UpdateDate: 2020/9/5 20:48
	 * @UpdateRemark: 修改内容
	 * @Version: 1.0
	 */
	public HttpResult startSubmitOrderByReentrantLock(Long seckillId, String userId);


	/**
	 * @Description: redis分布式锁的方式进行上锁
	 * @Author: hubin
	 * @CreateDate: 2020/9/12 22:20
	 * @UpdateUser: hubin
	 * @UpdateDate: 2020/9/12 22:20
	 * @UpdateRemark: 修改内容
	 * @Version: 1.0
	 */
/*	public HttpResult startSubmitOrderByRedissonLock(Long seckillId, String userId);*/


	/**
	 * @Description: 7-1 使用redisson分布式锁方案控制库存，实现下单
	 * @Author: hubin
	 * @CreateDate: 2020/9/5 20:48
	 * @UpdateUser: hubin
	 * @UpdateDate: 2020/9/5 20:48
	 * @UpdateRemark: 修改内容
	 * @Version: 1.0
	 */
	public HttpResult startSubmitOrderByZookeeperLock(Long seckillId, String userId);


/*	public void sendMessageTransaction(String seckillId,String userId);*/

	public void updateOrderStatus(String out_trade_no, String transaction_id);


	public TbPayLog searchPayLogFromRedis(String userId);

	/**
	 * @Description: 从redis中查询用户信息
	 * @Author: hubin
	 * @CreateDate: 2020/6/10 10:47
	 * @UpdateUser: hubin
	 * @UpdateDate: 2020/6/10 10:47
	 * @UpdateRemark: 修改内容
	 * @Version: 1.0
	 */
	FrontUser getUserInfoFromRedis(String token);

    HttpResult getOrderMoney(Long orderId);

	TbSeckillOrder findOrderById(Long orderId);

	public void getSeckillGoods(Long seckillId);
}
